package com.lsy.android.pingpang.view;

import java.util.ArrayList;

import com.lsy.android.pingpang.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BluetoothViewAdapter extends BaseAdapter {

	private Context mContext;
	private ArrayList<String> mNameList;

	public BluetoothViewAdapter(Context context, ArrayList<String> names) {
		mContext = context;
		mNameList = names;
	}

	@Override
	public int getCount() {
		return mNameList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.bluetooth_item, null);
			holder = new Holder();
			holder.name = (TextView) convertView.findViewById(R.id.name);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		holder.name.setText(mNameList.get(position));
		return convertView;
	}

	class Holder {
		TextView name;
	}

}
